home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pbaseiv.zip / P4DOS004.TIP < prev    next >
Text File  |  1991-12-16  |  3KB  |  75 lines

  1. Due to unruly applications, inexperienced users who share my
  2. PC, and a hard disk that's full to overflowing, I have to
  3. run CHKDSK frequently. However, I don't want to review the
  4. results of the check unless there's a problem. I therefore
  5. use a sequence of batch commands below to keep
  6. CHKDSK in the background--unless it finds something
  7. important.
  8.  
  9. The batch works because the DOS COPY command won't copy
  10. zero-length files--a quirk I've often found useful in
  11. conjunction with the FIND filter.
  12.  
  13. Jim White
  14. Fargo, North Dakota
  15.  
  16. Editor's note: Mr. White's batch routine uses some clever
  17. tricks to do its job. After writing the results of a CHKDSK
  18. to a file (instead of the screen), the batch uses the FIND
  19. command three times to search this file for warning phrases
  20. that CHKDSK might have written, sending the results to three
  21. new files. If FIND doesn't find anything--in other words, if
  22. CHKDSK found no problems--all three FIND-created files will
  23. be empty. Since COPY won't work on a zero-length file,
  24. CHK.$$5 won't be created, and a simple `if not exist...go
  25. to' statement will direct your batch file elsewhere.
  26.  
  27. This technique can be used in any batch where you want to
  28. perform a specific action if the FIND command found
  29. something--or didn't. This lets you monitor the output of
  30. many DOS utilities, including CHKDSK, ATTRIB, and DIR, for
  31. lines that indicate your system requires attention. To run
  32. CHKDSK every day without being bothered with the results,
  33. put White's commands--or something like them--into your
  34. AUTOEXEC.BAT file. And if you have a RAM disk, you can speed
  35. up your batch by writing all those temporary files to it.
  36. You can copy the listing to a file with the Alt-F key and
  37. customize it for your own use.
  38.  
  39. Postscript: When this batch was originally published, a
  40. few readers reported that it sometimes "hung up" when used
  41. to test a disk. We traced this problem to CHKDSK's "lost
  42. clusters" report. Most versions of CHKDSK stop and ask you
  43. if you want to convert lost clusters to files even when you
  44. have not specified the /F parameter (required for fixes to
  45. be made)!
  46.  
  47. The solution was to use the echo command to send a "y" to
  48. CHKDSK, just in case it required a response. The listing
  49. below reflects that change.
  50.  
  51. Reporting CHKDSK errors
  52.  
  53. ---- BEGIN LISTING ----
  54. @echo off
  55. echo Checking for disk problems....
  56. if exist c:\tmp\chk.$* del c:\tmp\chk.$*
  57. chkdsk < echo y> c:\tmp\chk.$1
  58. find "non-contiguous" < c:\tmp\chk.$1 > c:\tmp\chk.$$2
  59. find "lost clusters" < c:\tmp\chk.$1 > c:\tmp\chk.$$3
  60. find "cross-linked" < c:\tmp\chk.$1 > c:\tmp\chk.$$4
  61. copy c:\tmp\chk.$$? c:\tmp\chk.$5 > nul
  62. if not exist c:\tmp\chk.$5 goto continue
  63. echo CHKDSK reports potential problems:
  64. more < chk.$1
  65. pause
  66. :continue
  67. del c:\tmp\chk.$*
  68. ---- END LISTING ----
  69.  
  70. Title: Checking Up on CHKDSK
  71. Category: DOS
  72. Issue date: Nov 1991
  73. Editor: Brett Glass
  74. Supplementary files: NONE
  75.